package com.cf.wal.model;

import com.cf.crud.entity.BaseEntity;

import javax.persistence.*;
import java.util.Date;

/**
 * boot-awm-Wal
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/7/4 下午 04:21
 */
@Entity
@Table(name = "wal")
public class Wal extends BaseEntity {

    /**
     * 用于确定日志执行的先后顺序
     */
    @Column(name = "sort")
    private long sort;

    /**
     * 接收到的操作命令
     */
    @Column(name = "sort")
    private String command;

    /**
     * 这个是用来回滚的数据，交由执行引擎处理
     * undo 数据
     */
    @Column(name = "redo")
    private String redo;

    /**
     * 这个是用来恢复的数据，交由执行引擎处理
     * redo数据
     */
    @Column(name = "undo")
    private String undo;

    /**
     * 日志的状态
     */
    @Column(name = "state")
    private String state;

    @Column(name = "addTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date addTime = new Date();

    public String getCommand() {
        return command;
    }

    public void setCommand(String command) {
        this.command = command;
    }

    public long getSort() {
        return sort;
    }

    public void setSort(long sort) {
        this.sort = sort;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getRedo() {
        return redo;
    }

    public void setRedo(String redo) {
        this.redo = redo;
    }

    public String getUndo() {
        return undo;
    }

    public void setUndo(String undo) {
        this.undo = undo;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    @Override
    public String toString() {
        return "Wal{" +
                "sort=" + sort +
                ", command='" + command + '\'' +
                ", redo='" + redo + '\'' +
                ", undo='" + undo + '\'' +
                ", state='" + state + '\'' +
                ", addTime=" + addTime +
                '}';
    }
}
